package com.example.service;

import com.example.entity.InsuredPerson;
import com.example.mapper.InsuredPersonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InsuredPersonService {
    
    @Autowired
    private InsuredPersonMapper insuredPersonMapper;

    public void registerInsuredPerson(InsuredPerson person) {
        insuredPersonMapper.insert(person);  // 创建参保人员
    }

    public InsuredPerson getInsuredPersonById(int id) {
        return insuredPersonMapper.selectById(id);  // 查询参保人员
    }

    public List<InsuredPerson> getAllInsuredPersons() {
        return insuredPersonMapper.selectList(null);  // 查询所有参保人员
    }

    public void updateInsuredPerson(InsuredPerson person) {
        insuredPersonMapper.updateById(person);  // 更新参保人员
    }

    public void deleteInsuredPerson(int id) {
        insuredPersonMapper.deleteById(id);  // 删除参保人员
    }
}
